#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int arrn[1000] = { 0 };
	int arrm[1000] = { 0 };

	for (int i = 0; i < n; i++)
		scanf("%d", &arrn[i]);
	for (int j = 0; j < m; j++)
		scanf("%d", &arrm[j]);
	int i = 0;
	int j = 0;
	while (i < n && j < m)
	{
		if (arrn[i] < arrm[j])
		{
			printf("%d ", arrn[i]);
			i++;
		}
		else
		{
			printf("%d ", arrm[j]);
			j++;
		}
	}
	while (i < n)
	{
		printf("%d ", arrn[i]);
		i++;
	}
	while (j < m)
	{
		printf("%d ", arrm[j]);
		j++;
	}

	return 0;
}